import React from 'react'
import { Tabs } from 'react-vant';
import {
    useSelector,
    useDispatch
} from "react-redux"
import * as api from "../api/index"

function Son() {
    const dispatch = useDispatch()
    // 从仓库里取数据
    const data = useSelector(state=>{
        // console.log(state);
        return state.reudcer.data
    })
    const childrenData = useSelector(state=>{
        // console.log(state);
        return state.reudcer.childrenData
    })
    
    const set_children = (index) =>{
        dispatch(api.set_children_data(index))
    }
  return (
    <div>
        Son
        <Tabs active={0} onChange={set_children}>
        {
            data&&data.map((item) => (
                <Tabs.TabPane key={item.key} title={item.name}>
                    {
                        childrenData&&childrenData.map((val,i)=>(
                            <div key={i}>{val.date}</div>
                        ))
                    }
                </Tabs.TabPane>
        ))}
        </Tabs>

    </div>
  )
}

export default Son